package io.renren.modules.user.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.modules.user.entity.TbUserEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.user.service.TbUserService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author LL
 * @email wdlyl@163.com
 * @date 2022-04-12 14:48:24
 */
@Api("用户相关")
@RestController
@RequestMapping("/car/user1")
public class TbUserController {
    @Autowired
    private TbUserService tbUserService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("car:user1:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbUserService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("获取用户信息")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("car:user1:info")
    public R info(@ApiParam("用户id") @PathVariable("id") String id){
		TbUserEntity user1 = tbUserService.getById(id);

        return R.ok().put("user1", user1);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("car:user1:save")
    public R save(@RequestBody TbUserEntity user1){
		tbUserService.save(user1);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("car:user1:update")
    public R update(@RequestBody TbUserEntity user1){
		tbUserService.updateById(user1);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("car:user1:delete")
    public R delete(@RequestBody String[] ids){
		tbUserService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
